<cfcomponent output="false">
	<cfset this.name = "CFSmugAPITest" />
	<cfset this.applicationTimeout = createTimeSpan(0,2,0,0) />
	<cfset this.clientManagement = false />
	<cfset this.clientStorage = "cookie" />
	<cfset this.loginStorage = "session" />
	<cfset this.sessionManagement = true />
	<cfset this.sessionTimeout = createTimeSpan(0,0,20,0) />
	<cfset this.setClientCookies = true />
	<cfset this.setDomainCookies = false />
	<cfset this.scriptProtect = true />

	<cffunction name="onApplicationStart" returnType="boolean" output="false">
		<cfscript>
			Application.config.FileSeparator = createObject("java","java.io.File").separator;

			Application.CFSmugConfigObj = createObject( "component", "smug.CFSmugConfig" ).init( APIKey = "YOU-API-KEY",
				 																			 	 userAgent = "CFSmug Unit Tests $Revision$",
				 																			 	 debugEnabled = true );
		</cfscript>

		<cfreturn true />
	</cffunction>

	<cffunction name="onApplicationEnd" returnType="void" output="false">
		<cfargument name="applicationScope" required="true" />
	</cffunction>

	<cffunction name="onRequestStart" returnType="boolean" output="false">
		<cfargument name="thePage" type="string" required="true" />

		<cfset structAppend( Request, url, true ) />
		<cfset structAppend( Request, form, true ) />

		<cfif StructKeyExists( Request, "refreshApp") or true>
			<cfset onApplicationStart() />
		</cfif>

		<!--- Regular maintenance is done late at night. During those hours, tell
			  people to come back later, and do not process the request further. --->
		<!---
		<cfif ( ( Hour( now() ) gt 1 ) and ( Hour( now() ) lt 3 ) )>
			<cfdump var="#The system is undergoing periodic maintenance.  Please return after 3:00 AM Eastern time.#" />
			<cfreturn false />
		<cfelse>
			<cfset this.start = now() />
			<cfreturn true />
		</cfif>
		 --->


		<!--- Check for login here --->


		<cfset this.start = now() />

		<cfreturn true />
	</cffunction>


	<cffunction name="onRequest" returnType="void">
		<cfargument name="thePage" type="string" required="true" />

		<cfinclude template="_header.cfm" />
		<cfinclude template="#ListLast( Arguments.thePage, "/" )#" />
		<cfinclude template="_footer.cfm" />

	</cffunction>


	<cffunction name="onRequestEnd" returnType="void" output="false">
		<cfargument name="thePage" type="string" required="true" />
	</cffunction>

	<cffunction name="onError" output="true">
		<cfargument name="exception" required="true" />
		<cfargument name="eventName" type="string" required="true" />
		<!--- Log all errors --->


		<!--- Display an error message if there is a page context. --->
		<cfif ( trim( Arguments.eventName ) neq "onSessionEnd" ) AND
			  ( trim( Arguments.eventName ) neq "onApplicationEnd" )>

			<cflog file="#this.name#" type="error"
				   text="Event name: #Arguments.eventName#" />

			<cflog file="#this.name#" type="error"
				   text="Message: #Arguments.exception.message#" />

			<cfoutput>
				<h2>An unexpected error occurred.</h2>
				<p>Please provide the following information to technical support:</p>
				<p>Error Event: #Arguments.eventName#</p>
				<p>Error details:</p>
			</cfoutput>

			<cfdump var="#Arguments.exception#" />

		<cfelseif ( Arguments.eventName eq "onApplicationEnd" )>
			<cflog file="#this.name#" type="Information"
				   text="Application #this.name# Ended" />
		</cfif>
	</cffunction>

	<cffunction name="onSessionStart" returnType="void" output="false">

	</cffunction>

	<cffunction name="onSessionEnd" returnType="void" output="false">
		<cfargument name="sessionScope" type="struct" required="true" />
		<cfargument name="appScope" type="struct" required="false" />
	</cffunction>
</cfcomponent>